import java.util.StringTokenizer;

class P108 {

	static S s = new S();

	private static int[][] matrix;

	private static int n;

	private static int[][] sumMatrix;


	public static void main(String[] args) {
		n = Integer.parseInt(readLn());
		matrix = new int[n][n];
		sumMatrix = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				matrix[i][j] = s.getInt();
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				sumMatrix[i][j] = getSum(i, j);
			}
		}		
		
		int maxSum = Integer.MIN_VALUE;

//		and if you have this table the sum of the rectangle for exmple form 2,2 to 4,5 is equal to :
//			B[4,5]-B[4,1]-B[1,5]+B[1,1]
		
		for (int i0 = 0; i0 < n; i0++) {
			for (int j0 = 0; j0 < n; j0++) {
				for (int iF = i0; iF < n; iF++) {
					for (int jF = j0; jF < n; jF++) {
						int sum = sumMatrix[iF][jF] - ((j0 - 1 == -1) ? 0 : sumMatrix[iF][j0-1]) - ((i0 - 1 == -1) ? 0 : sumMatrix[i0-1][jF]) + ((i0 - 1 == -1 || j0 - 1 == -1) ? 0 : sumMatrix[i0-1][j0-1]);
						if (sum > maxSum) {
							maxSum = sum;
						}
					}
				}
			}
		}

		System.out.println(maxSum);
	}

//	the B[i,j] = sum (from 1 to i and form 1 to j of A) 
	private static int getSum(int iF, int jF) {
		int sum = 0;
		for (int i = 0; i <= iF; i++) {
			for (int j = 0; j <= jF; j++) {
				sum += matrix[i][j];
			}
		}
		
		return sum;
	}


	private static int getMaxSumOf(int i0, int j0) {
		int maxSum = Integer.MIN_VALUE;
		for (int i = i0; i < n; i++) {
			for (int j = i0; j < n; j++) {
				int sum = 0;
				for (int l = i0; l <= i; l++) {
					for (int m = j0; m <= j; m++) {
						sum += matrix[l][m];
					}
				}
				if (sum > maxSum) {
					maxSum = sum;
				}
			}
		}
		return maxSum;
	}


	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

}

class S {

	StringTokenizer st = null;


	int getInt() {
		if (st == null)
			st = new StringTokenizer(R.readLn());
		while (!st.hasMoreTokens())
			st = new StringTokenizer(R.readLn());
		return Integer.parseInt(st.nextToken());
	}

}

class R {
	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}
}